package com.ruoyi.report.forms.controller;

import com.alibaba.fastjson.JSON;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.client.WebClient;

@RestController
@RequestMapping("/predict")
public class PredictControlller {

    WebClient client;

    public PredictControlller() {
        client = WebClient.create();
    }

    @PostMapping("nextValue")
    public void reply() {
        String[] data = new String[]{"1", "2", "3", "4", "5", "6", "7"};
        String json = JSON.toJSONString(data);
        String obj = client.post()
                .uri("http://localhost:12315/predict/nextValue")
                .contentType(MediaType.APPLICATION_JSON)
                .body(BodyInserters.fromValue(json))
                .retrieve()
                .bodyToMono(String.class)
                .block();
        System.out.println(obj);
    }
}
